package com.xizi.秋招笔试.tx;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author xizizzz
 * @description: TODO
 * @date 2021-8-22下午 08:45
 */
public class tx2 {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        while (T-- > 0) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++) {
                a[i] = scanner.nextInt();
            }
            Arrays.sort(a);
            int len = a.length;
            int res = 0;
            for (int i = len - 1; i >= 0; i--) {
                res += a[i];
                res += a[i] * ((i * (i + 1)) / 2);
            }
            System.out.println(res % 1000000007L);
        }
    }
}
